package com.example.blogsystem.service;

import com.example.blogsystem.dao.UserMapper;
import com.example.blogsystem.model.Userinfo;
import com.example.blogsystem.model.vo.UserinfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DELL
 * Date: 2023-09-03
 * Time: 23:15
 */

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 注册业务
     *
     * @param userinfo
     * @return 注册成功: 1
     * 用户名已存在: -1
     */
    public int reg(Userinfo userinfo) {
        return userMapper.reg(userinfo);
    }

    /**
     * 根据用户名查询用户信息
     *
     * @param username
     * @return
     */
    public Userinfo getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    /**
     * 根据用户 id 查询用户详细信息
     *
     * @param uid
     * @return
     */
    public UserinfoVO getUserById(int uid) {
        return userMapper.getUserById(uid);
    }
}
